import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { SIntegralExchangeRecord } from "../../../../../Message/Public/SIntegralExchangeRecord";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { ItemData } from "../../../resource/info/ItemData";
import { Language } from "../../../../../extend/language/Language";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { ObjCreate } from "../ObjCreate";
import { ClickToShowItemTip } from "../tooltip/ClickToShowItemTip";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class IntegralShopRecordCellRenderer
    
    export  class IntegralShopRecordCellRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            this.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.onRemoveFromStageHandler);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._record = arg1 as SIntegralExchangeRecord;
            if (this._record) 
            {
                this._unitName = GameDefConfig.instance.getEPrictUnitName(this._record.unit);
                this._itemData = new ItemData(this._record.itemCode);
                this._txt.htmlText = Language.getStringByParam(35052, this._record.playerName, this._record.cost, this._unitName, this._itemData.itemCode, ItemsUtil.getItemName(this._itemData));
                this._txt.addEventListener(flash.events.TextEvent.LINK, this.onTxtLinkHandler);
            }
            return;
        }

        /* internal  */init(): void
        {
            this._txt = ObjCreate.createGTextField("", 0, 0, 210, 40, this);
            this._txt.wordWrap = true;
            this._txt.multiline = true;
            return;
        }

        /* internal  */onTxtLinkHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=int(arg1.text);
            this._isItemTip = true;
            ClickToShowItemTip.instance.setItemCodeAndShow(loc1);
            return;
        }

        /* internal  */onRemoveFromStageHandler(arg1: Object /* flash.events.Event */): void
        {
            if (this._isItemTip) 
            {
                this._isItemTip = false;
                ClickToShowItemTip.instance.hide();
            }
            return;
        }

        /* internal */ /* var */_txt: GTextFiled;

        /* internal */ /* var */_record: SIntegralExchangeRecord;

        /* internal */ /* var */_itemData: ItemData;

        /* internal */ /* var */_unitName: string;

        /* internal */ /* var */_isItemTip: Boolean=false;
    }
